package cn.biplam.setup.code;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.template.control.Panel;
import cn.biplam.front.template.main.PageSimple;
import cn.biplam.setup.code.ajx.AjxCodeManage;
import cn.biplam.setup.code.bean.BeanCodeMange;
import cn.biplam.setup.code.opera.OperaCodeManage;
import cn.biplam.setup.code.page.PageCodeManage;
import cn.biplam.setup.code.product.ProductManage;

/**
 * 交换代码管理界面
 * @author XiaoRuxing Sep 22, 20096:11:07 PM
 * @version 1.0
 */
public class CodeManageMain {

	private HttpServletRequest request=null;
	private HttpServletResponse response=null;
	private PageSimple page;
	String sHomeUrl;
	
	/**
	 * 构造方法S
	 * @param request
	 * @param response
	 */
	public CodeManageMain(HttpServletRequest request, HttpServletResponse response){
		this.request=request;
		this.response=response;
	}
	
	/**
	 * @throws ErrorMessage 
	 * 返回页面的HTML
	 */
	public void draw() throws ErrorMessage{
		UserInfo mUser =  new UserInfo();
		mUser.setUserID("-10000");
		mUser.setUserLanguage("1");
		mUser.setUserCallName("manage");
		request.getSession().setAttribute("userInfo",mUser);
		request.getSession().setMaxInactiveInterval(360000);
		try {
			this.response.setContentType("text/html"); 
			PrintWriter out = new PrintWriter (this.response.getOutputStream());
			
			this.sHomeUrl=request.getContextPath();
			this.page=new PageSimple("智能管理系统开发平台", sHomeUrl,mUser);
			
			/**放入用户ID*/
			page.setUserID(mUser.getUserID());
			
			Panel panel = new Panel("Code_Manage_Panal");
			panel.put("Ajx代码管理", 
					new AjxCodeManage().aId_main, ExchangeCodeData.Code_Type.Ajx_Code.toString());
			panel.put("Operator代码管理", 
					new OperaCodeManage().aId_main,  ExchangeCodeData.Code_Type.Operator_Code.toString());
			panel.put("页面代码管理", 
					new PageCodeManage().aId_main, ExchangeCodeData.Code_Type.Page_Code.toString());
			panel.put("Bean代码管理", 
					new BeanCodeMange().aId_main, ExchangeCodeData.Code_Type.Bean_Operator_Code.toString());
			panel.put("产品管理", 
					ProductManage.Get_Produc_Manage, ExchangeCodeData.Code_Type.Bean_Operator_Code.toString());
			
			/**放入右部功能区*/
			HtmlWindow win = panel.get();
			page.putDomain(win);
			out.println(page.get().draw());

			out.close();
		} catch(ErrorMessage e){
			throw e;
		} catch (Exception e) {
			throw new ErrorMessage(e);
		}
	}
}
